﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tssipl.PaymentAdapter.Core;
using Tssipl.PaymentAdapter.MessageFormat.Sfms;
using Tssipl.PaymentAdapter.MessageEntity.Sfms.Neft;
using Tssipl.PaymentAdapter.MessageEntity.Sfms.Rtgs;

namespace Tssipl.PaymentAdapter.MessageEntityFactory
{
    public class MessageFactory
    {
        public static MessageEntityBase GetMessageInstance(string messageToBeParsed)
        {
            MessageEntityBase financialMessage = null;
            if (messageToBeParsed.StartsWith("{A:"))
            {
                MessageParseResults results =SfmsMessageParser.parseMessage(messageToBeParsed);
 
                SfmsMessage message = (SfmsMessage)results.getMessage();
                string mt = message.getBlock1().MessageType;
                string smt = message.getBlock1().SubMessageType;
                if (mt== "298" && smt== "R42")
                    financialMessage=(new RtgsInterbankPaymentRequestOrNotification(results));
                if (mt == "298" && smt == "R41")
                    financialMessage = (new RtgsCustomerPaymentRequestOrNotification(results));
                if (mt == "298" && smt == "R10")
                    financialMessage = (new RtgsOwnAccountTransferRequest(results));
                if (mt == "298" && smt == "R91")
                    financialMessage = (new RtgsPHOrPHCancellationResponse(results));
                if (mt == "298" && smt == "R09")
                    financialMessage = (new RtgsSenderSettlementNotification(results));
                if (mt == "298" && smt == "R44")
                    financialMessage = (new RtgsCreditNotification(results));
                if (mt == "298" && smt == "R43")
                    financialMessage = (new RtgsDebitNotification(results));
                if (mt == "298" && smt == "N02")
                    financialMessage = (new NeftCreditTransaction(results));
                if (mt == "298" && smt == "N03")
                    financialMessage = (new NeftRejectRescheduleAtServiceCenter(results));
                if (mt == "298" && smt == "N04")
                    financialMessage = (new NeftEndOfDayEndOfBatch(results));
                if (mt == "298" && smt == "N06")
                    financialMessage = (new NeftOutwardDebitMessagesFromNeftBranches(results));
                if (mt == "298" && smt == "N07")
                    financialMessage = (new NeftReturnTransactionsFromNeftBranches(results));
                if (mt == "298" && smt == "N08")
                    financialMessage = (new NeftNilTransactionOrNilRejection(results));
                if (mt == "298" && smt == "N09")
                    financialMessage = (new NeftRejectedOrRescheduleAtNeftServiceBranches(results));
                if (mt == "298" && smt == "N10")
                    financialMessage = (new NeftOutwardInwardCreditConfirmation(results));
                if (mt == "298" && smt == "N90")
                    financialMessage = (new NeftN90Specification(results));

                //financialMessage.Block1 = ((SfmsMessage)financialMessage.Results.getMessage()).getBlock1();
            }
            else
            {

            }
            return financialMessage;
        }
    }
   
   

    
   
}
